﻿using System;

namespace GenUI.WPF.GenControls
{
    public class Log
    {
        private string _LogMsg = string.Empty;
        private LogLevel _LogLevel;
        private DateTime _LogTime = DateTime.Now;
        public string ShowLog { get => GetLogStr(); } 
        public string LogMsg
        {
            get => _LogMsg;
            set => _LogMsg = value;
        }
        public LogLevel LogLevel
        {
            get => _LogLevel;
            set => _LogLevel = value;
        }
        public DateTime LogTime
        {
            get => _LogTime;
            set => _LogTime = DateTime.Now;
        }
        public Log(string logmsg, LogLevel logLevel)
        {
            LogMsg = logmsg;
            LogLevel = logLevel;
        }
        public string GetLogStr()
        {
            string lever = string.Empty;
            switch (LogLevel) 
            { 
                case LogLevel.Tips:
                    lever = "提示";
                    break;
                case LogLevel.Important:
                    lever = "重要";
                    break;
                case LogLevel.Error:
                    lever = "错误";
                    break;
                case LogLevel.Debug:
                    lever = "调试";
                    break;
            }
            return $"[{lever}] [{LogTime:yyyy-MM-dd HH:mm:ss:fff}] : {LogMsg}";
        }
    }
}
